// app.js
import "./utils/utils"
import './utils/request'
App({
  token: "",
  refreshToken: "",
  globalData: {},
  // 存储token
  setToken(token, refreshToken) {
    // 存储token
    const myToken = `Bearer ${token}`
    this.token = myToken
    wx.setStorageSync('token', myToken)
    // 存储refreshToken
    const myRefreshToken = `Bearer ${refreshToken}`
    this.refreshToken = myRefreshToken
    wx.setStorageSync('refreshToken', myRefreshToken)
  },
  // 删除token
  removeToken() {
    this.token = ''
    this.refreshToken = ''
    wx.removeStorageSync('token')
    wx.removeStorageSync('refreshToken')
  },
  onLaunch() {
    // 取token
    this.token = wx.getStorageSync('token')
    // 取refreshToken
    this.refreshToken = wx.getStorageSync('refreshToken')
  }
})